<template>
  <div style="margin-top: 10px;">
    <div class="search_form">
      <form action="#" method="post">
        <input type="search"  v-model="keyword" placeholder="手机/电脑/家电/服饰..." :style="{borderColor: focused ? '007BFF' : '#007BFF'}" />
        <button type="button" class="image-search-btn" title="图片搜索">
          <span class="icon">📷</span>
        </button>
        <input type="button" value="搜索" @click="search" />
      </form>
    </div>
  </div>
</template>

<script setup>
// 搜索框组件逻辑
import { ref } from 'vue'
let focused = ref(false)
let keyword = ref('');
const emit = defineEmits(['search']);

const search = () => {
  emit('search', keyword.value.trim());
}
</script>

<style scoped>
.search_form {
  text-align: center;
  margin: 20px 0;
}

.search_form form {
  display: inline-flex;
  border-radius: 25px;
  overflow: hidden;
  box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
}

.search_form input[type="search"] {
  flex: 1;
  width: 360px;
  padding: 12px 20px;
  border: 2px solid #007BFF;
  border-right: none;
  font-size: 16px;
  outline: none;
  border-radius: 25px 0 0 25px;
}

.search_form input[type="search"]:focus {
  border-color: #0056b3;
}

.search_form .image-search-btn {
  padding: 12px 15px;
  background-color: #f8f9fa;
  border-top: 2px solid #007BFF;
  border-bottom: 2px solid #007BFF;
  border-left: none;
  border-right: none;
  cursor: pointer;
  transition: background-color 0.3s;
}

.search_form .image-search-btn:hover {
  background-color: #e9ecef;
}

.search_form .image-search-btn .icon {
  font-size: 18px;
}

.search_form input[type="button"] {
  padding: 12px 30px;
  background-color: #007BFF;
  border: 2px solid #007BFF;
  color: white;
  font-size: 16px;
  cursor: pointer;
  transition: background-color 0.3s;
  border-radius: 0 25px 25px 0;
}

.search_form input[type="button"]:hover {
  background-color: #0056b3;
}
</style>